package aom.ju.ss.utils.provinceCityDistrict

import android.app.Activity
import androidx.recyclerview.widget.LinearLayoutManager
import aom.ju.ss.R
import aom.ju.ss.databinding.ListDialog2Binding
import aom.ju.ss.databinding.ListDialogTemBinding
import aom.ju.ss.lpInterface.ListDialogCallBack
import aom.ju.ss.view.base.PAdapter
import aom.ju.ss.view.dialog.BaseDialog


/**
 * 街道选择器
 */
class ListDialog(activity: Activity, list: List<StreetInfo>, call: ListDialogCallBack) :
    BaseDialog(activity) {

    override fun isBottom(): Boolean {
        return true
    }
    init {
        setWidth(-1)
        val binding = vBinding as ListDialog2Binding
        binding.recStart.layoutManager = LinearLayoutManager(activity)
        binding.title.text = "请选择街道/乡镇"
        binding.recStart.adapter = PAdapter(
            list, R.layout.list_dialog_tem
        ) { bb, position ->
            val ib = bb as ListDialogTemBinding
            ib.tv.text = list[position].name
            ib.tv.setOnClickListener {
                call.ck(list[position], position)
                dis()
            }
        }

    }

    override fun init() {


    }

    override fun getLay(): Int {
        return R.layout.list_dialog_2
    }
}